<!--
- Author:   .
- Date:    2017/11/1 0001.
- File:    baidu.
-->
<template>
  <div>
    <span class="cr_45a73a" style="position: fixed; right: 20px; top: 20px; font-size: 14px; background: #fff; padding: 2px 5px;" @click="wxShare" v-show="$deviceType == 'APICloud' && share == 'true'">分享</span>
    <iframe id="iframe1" style="width: 100%; height: 26rem" :src="url" frameborder="0" @load="fixIosIframeWidthBug"></iframe>
    <footer-tab></footer-tab>
  </div>
</template>

<script>
  export default{
    data() {
      return {
        share: this.$route.query.share || '',
        url: this.$route.query.url,
        title: this.$route.query.title || '淘花1'
      }
    },
    components: {},
    created() {
      // this.$native.weixinShare(window.location.href)
    },
    methods: {
      fixIosIframeWidthBug() { // ios iframe 宽度会撑开bug
        if (!navigator.userAgent.match(/iPad|iPhone/i)) {
          return false
        }
        var iframebody = document.getElementById('iframe1').contentWindow.document.body
        iframebody.style.width = document.body.clientWidth + 'px'
      },
      wxShare() {
        let _this = this
        var wx = window.api.require('wx')
        wx.shareWebpage({
          apiKey: '',
          scene: 'session',
          title: _this.title,
          description: '分享',
          contentUrl: _this.url
        }, function(ret, err) {
          if (ret.status) {
            this.$toast('分享成功')
          } else {
            this.$toast('分享失败:' + err.code)
          }
        })
      }
    }
  }
</script>

<style>

</style>